package com.aaa.stock.mapper;

import com.aaa.entity.stock.Stock;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author aaa
 * @since 2020-11-28
 */
@Component
public interface StockMapper extends BaseMapper<Stock> {
    @Select("select commoditybar from b_stock where warehouseid=#{warehouseid}")
    List<String> selectCommoditybarByWarehouseid(Long warehouseid);
    @Select("select sum(uqty) from b_stock s\n" +
            "join b_locator l on s.locatorcode = l.code\n" +
            "where s.commoditybar=#{commoditybar} and s.warehouseid=#{warehouseid} and not l.type=2")
    Integer selectSumUqtyByCommoditybar(String commoditybar, Long warehouseid);
    @Select("select * from b_stock s join b_locator l \n" +
            "on s.locatorcode=l.code \n" +
            "where s.warehouseid=#{warehouseid} and s.commoditybar=#{commoditybar} and not l.type=2")
    List<Stock> selectStockByCommoditybar(String commoditybar, Long warehouseid);

    //查询41仓库且不在入库区的库存
    @Select("select distinct commoditybar,commodityname from b_stock s\n" +
            "join b_locator l on l.code=s.locatorcode\n" +
            "where s.warehouseid=41 and not l.type=2")
    List<Stock> selectStockByHouse();

    @Select("select * from b_stock where warehouseid=42 and uqty>0")
    List<Stock> selectStoCom();

    @Select("select * from b_stock where locatorcode=#{locatorcode} and commoditybar=#{commoditybar}")
    Stock selectStockByCommodity(String locatorcode,String commoditybar);
}
